package cn.mianshiyi.monitor;


import java.util.HashMap;
import java.util.Map;

/**
 * @author shangqing.liu
 */
public abstract class MonitorCounter {

    protected String monitorName;
    protected String description;
    protected Map<String, String> labelMap = new HashMap<>();

    /**
     * 获取监控对象的名称
     * @return
     */
    public String getMonitorName() {
        return monitorName;
    }

    public void setMonitorName(String monitorName) {
        this.monitorName = monitorName;
    }

    /**
     * 设置监控对象的描述信息
     * @param description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * 获取监控對象的监控描述信息
     * @return
     */
    public String getDescription() {
        return description;
    }

    /**
     * 获取监控對象的监控数据并且重置数据。
     * @return
     */
    public abstract Number getValueAndReset();

    /**
     * 计数，次数或者时间
     */
    public abstract void addValue(Number value);

    public Map<String, String> getLabelMap() {
        return labelMap;
    }

    public String getLabelValue(String labelName) {
        return labelMap.get(labelName);
    }

    public void putLabel(String labelName, String labelValue) {
        labelMap.put(labelName, labelValue);
    }

}
